#!/bin/bash
. $PROJECT_BASE/src/test/resources/testEnv.sh
. $PROJECT_BASE/src/main/scripts/utils/properties.sh

testGetProperty(){
    local espected="Gómez"
    echo "person.name=Carlos" > $PROJECT_BASE/target/testGetPropeties.properties
    echo "person.surname=Gómez" >> $PROJECT_BASE/target/testGetPropeties.properties
    #Incorrect params
    local result=( $(getProperty "$PROJECT_BASE/target/testGetPropeties.properties") )
    local calculated=`echo ${result[@]}`
    assertEquals "[ERROR]: Incorrect params" "${calculated}"
    local result=( $(getProperty "$PROJECT_BASE/target/testGetPropeties.properties" "person.surname") )
    local calculated=`echo ${result[@]}`
    assertEquals "$espected" "$calculated"
    local result=( $(getProperty "$PROJECT_BASE/target/testGetPropeties.properties" "person.age") )
    local calculated=`echo ${result[@]}`
    assertEquals "" "$calculated"
    local result=( $(getProperty "notExistFile.properties" "person.surname") )
    local calculated=`echo ${result[@]}`
    assertEquals "[ERROR]: The file notExistFile.properties isn't exist" "$calculated"
    rm -Rf $PROJECT_BASE/target/testGetPropeties.properties
}


$SHUNIT2